﻿@model Tuple<IEnumerable<HCM_maps_website.Process.Address>,int>

@{
    ViewBag.Title = "Address";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

<div id="content_page" class="address_page">
    <div id="data_content">
        <table cellpadding="0" cellspacing="0">
            <tr>
                <th>ID</th>
                <th>Number</th>
                <th>Area</th>
                <th>xLocation</th>
                <th>yLocation</th>
            </tr>
            @foreach(var addr in Model.Item1){ 
                <tr>
                    <td name="id">@addr.ID</td>
                    <td name="number">@addr.Number</td>
                    <td name="area">@addr.Area</td>
                    <td name="xlocation">@addr.xLocation</td>
                    <td name="ylocation">@addr.yLocation</td>
                </tr>
            }
        </table>
    </div>
    <div id="pagination">
        <form id="submitpage" action="@Url.Action("Address")">
            <select name="ipage" onchange="SubmitForm('submitpage')">
                @if(@Model.Item2>HCM_maps_website.Controllers.AdminController.NUM_RECORD_PER_PAGE){
                    var page = (((@Model.Item2 % HCM_maps_website.Controllers.AdminController.NUM_RECORD_PER_PAGE != 0) ? 1 : 0) + @Model.Item2 / HCM_maps_website.Controllers.AdminController.NUM_RECORD_PER_PAGE);
                    for (int i = 0; i < page; i++)
                     {
                        if(Session["page"]!=null && (int)Session["page"] == i+1){
                        <option selected value="@(i+1)">page @(i+1)</option>
                        }else{
                            <option value="@(i+1)">page @(i+1)</option>
                        }
                    
                     }
                }
            </select>
        </form>
    </div>
    <div class="clear"></div>
    <form id="EditForm" class="Processdata" action="@Url.Action("EditAddress")">
        <span class="row"><label>Address Info:</label></span>
        <span class="row"><label>ID:</label><label name="id"></label><input type="hidden" name="id" />
        <span class="elright"><label>Number:</label><input type="text" name="number"/></span></span>
        <span class="row"><label>Area:</label><input name="area" class="elmax" type="text"/></span>
        <span class="row"><label>xLocation:</label><input name="xlocation" type="text"/>
        <span class="elright"><label>yLocation:</label><input name="ylocation" type="text"/></span></span>

        <span class="row"><input type="submit" id="update" value="Update"  name="editadd"/>
        <input type="submit" value="Delete" id="delete" name="editadd" /></span>
        <div class="clear"></div>
    </form>

    <form id="AddForm" class="Processdata" action="@Url.Action("InsertAddress")">
        <span class="row"><label>Address Info:</label><input id="copyabove" style="margin-left:50px;" type="submit" value="Copy Above" onclick="return false;" /></span>
        <span class="row"><label>ID:</label><label name="id"></label>
        <span class="elright"><label>Number:</label><input type="text" name="number"/></span></span>
        <span class="row"><label>Area:</label><input class="elmax" type="text" name="area"/></span>
        <span class="row"><label>xLocation:</label><input type="text" name="xlocation"/>
        <span class="elright"><label>yLocation:</label><input type="text" name="ylocation"/></span></span>

        <span class="row"><input type="submit" value="Add" /></span>
        <div class="clear"></div>
    </form>
</div>